﻿<Window x:Class="ULSDeobfuscator.EditComplexFilterWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="{Binding Title, Mode=OneTime}" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:ULSDeobfuscator="clr-namespace:ULSDeobfuscator"
        xmlns:MvvmHelpers="clr-namespace:Elca.MvvmHelpers" 
        mc:Ignorable="d" 
        d:DataContext="{d:DesignInstance Type=ULSDeobfuscator:EditComplexFilterViewModel}"
        d:DesignHeight="250" d:DesignWidth="300"
        FocusManager.FocusedElement="{Binding ElementName=_txtExpression}"
        MvvmHelpers:LifetimeEvent.Loaded="{Binding LoadCommand}"
        Left="{Binding WindowLeft, Mode=TwoWay}"
        Top="{Binding WindowTop, Mode=TwoWay}" 
        ShowInTaskbar="False">
    
    <Window.Resources>


    </Window.Resources>
    <Grid Margin="5">
        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="3" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="3" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="10" />
            <RowDefinition Height="*" />
            <RowDefinition Height="3" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        
        <TextBlock Text="Expression: " 
                   Margin="5"
                   VerticalAlignment="Center"/>
        <TextBox Grid.Column="1"
                 x:Name="_txtExpression"
                 Margin="5"
                 Text="{Binding Filter.FilterExpression, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
        
        <CheckBox IsChecked="{Binding IsRegularExpression, Mode=TwoWay}"
                    Grid.Row="2" Grid.ColumnSpan="2"
                  Margin="10,5,0,0"
            >
            This is a regular expression
        </CheckBox>
        
        <CheckBox Grid.Row="4" Grid.ColumnSpan="2"
                  IsChecked="{Binding IsCaseSensitive, Mode=TwoWay}"
                  Margin="10,5,0,0"
                  Content="The expression is case-sensitive" />

        <GroupBox Grid.Row="6" Grid.ColumnSpan="2"
                  Header="Match Result">
            <!-- 2 inner grids are necessary for the scroll viewer to be effective -->
            <Grid>

                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>


                <ScrollViewer VerticalScrollBarVisibility="Auto">

                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Text="Try it on: "
                                   Margin="5"
                                   VerticalAlignment="Top"/>
                        <TextBox Text="{Binding TestMessage, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                 Grid.Column="1" 
                                 TextWrapping="Wrap"
                                 />
                    </Grid>
                </ScrollViewer>
                
                <TextBlock Text="{Binding MatchResult}" 
                               Grid.Row="1"
                               Margin="5,0,0,0" />
            </Grid>
        </GroupBox>

        <StackPanel Orientation="Horizontal"
                    Grid.Row="8" Grid.ColumnSpan="2"
                    Margin="0,10,5,0"
                    HorizontalAlignment="Right">
            <Button Content="OK"
                    Style="{StaticResource LargeButtonStyle}"
                    IsDefault="True"
                    Command="{Binding OKCommand}" />
            <Button Content="Cancel"
                    Style="{StaticResource LargeButtonStyle}"
                    Margin="20,0,0,0"
                    IsCancel="True"
                    Command="{Binding CancelCommand}" />

        </StackPanel>
    </Grid>
</Window>
